#ifndef _LED_H
#define _LED_H

#include "gd32f4xx.h"

typedef enum{
    LED0,LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8
}LEDNUM;

#define LEDSW_PORT  GPIOC
#define LED0_PORT   GPIOB
#define LED1_PORT   GPIOD
#define LED2_PORT   GPIOD
#define LED3_PORT   GPIOD
#define LED4_PORT   GPIOD
#define LED5_PORT   GPIOD
#define LED6_PORT   GPIOD
#define LED7_PORT   GPIOD
#define LED8_PORT   GPIOD

#define LEDSW_PIN   BIT(6)
#define LED0_PIN    BIT(2)
#define LED1_PIN    BIT(8)
#define LED2_PIN    BIT(9)
#define LED3_PIN    BIT(10)
#define LED4_PIN    BIT(11)
#define LED5_PIN    BIT(12)
#define LED6_PIN    BIT(13)
#define LED7_PIN    BIT(14)
#define LED8_PIN    BIT(15)

#define LEDSW(x)	 do{x?gpio_bit_set(LEDSW_PORT,LEDSW_PIN ):gpio_bit_reset(LEDSW_PORT,LEDSW_PIN );}while(0)
#define LED0(x)	 	 do{x?gpio_bit_set(LED0_PORT,LED0_PIN   ):gpio_bit_reset(LED0_PORT,LED0_PIN   );}while(0)
#define LED1(x)	 	 do{x?gpio_bit_set(LED1_PORT,LED1_PIN   ):gpio_bit_reset(LED1_PORT,LED1_PIN   );}while(0)
#define LED2(x)	 	 do{x?gpio_bit_set(LED2_PORT,LED2_PIN   ):gpio_bit_reset(LED2_PORT,LED2_PIN   );}while(0)
#define LED3(x)	 	 do{x?gpio_bit_set(LED3_PORT,LED3_PIN   ):gpio_bit_reset(LED3_PORT,LED3_PIN   );}while(0)
#define LED4(x)	 	 do{x?gpio_bit_set(LED4_PORT,LED4_PIN   ):gpio_bit_reset(LED4_PORT,LED4_PIN   );}while(0)
#define LED5(x)	 	 do{x?gpio_bit_set(LED5_PORT,LED5_PIN   ):gpio_bit_reset(LED5_PORT,LED5_PIN   );}while(0)
#define LED6(x)	 	 do{x?gpio_bit_set(LED6_PORT,LED6_PIN   ):gpio_bit_reset(LED6_PORT,LED6_PIN   );}while(0)
#define LED7(x)	 	 do{x?gpio_bit_set(LED7_PORT,LED7_PIN   ):gpio_bit_reset(LED7_PORT,LED7_PIN   );}while(0)
#define LED8(x)	 	 do{x?gpio_bit_set(LED8_PORT,LED8_PIN   ):gpio_bit_reset(LED8_PORT,LED8_PIN   );}while(0)

#define LED0Toggle  gpio_bit_toggle(GPIOB,GPIO_PIN_2)

void Led_Init(void);
void Led_on(LEDNUM NUM);
void Led_off(LEDNUM NUM);
void Led_Allon(void);
void Led_Alloff(void);

void Led_Water(uint8_t start);

#endif 
